﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FigureDraw
{
    public class MyRectInfo
    {
        double x;
        double y;
        double width;
        double height;

        public MyPoint Position
        {
            get { return new MyPoint(x, y); }
            set
            {
                x = value.X;
                y = value.Y;
            }
        }

        public MyPoint Size
        {
            get { return new MyPoint(width, height); }
            set
            {
                width = value.X;
                height = value.Y;
            }
        }

        public MyRectInfo(double x, double y, double width, double height)
        {
            this.x = x;
            this.y = y;
            this.width = width;
            this.height = height;
        }

        public static MyRectInfo Convert(MyPoint startPoint, MyPoint endPoint)
        {
            double x = startPoint.X > endPoint.X ? endPoint.X : startPoint.X;
            double y = startPoint.Y > endPoint.Y ? endPoint.Y : startPoint.Y;
            double width = Math.Abs(startPoint.X - endPoint.X);
            double height = Math.Abs(startPoint.Y - endPoint.Y);

            return new MyRectInfo(x, y, width, height);
        }
    }
}
